package com.tedu.jdbc;

import com.tedu.utils.JDBCUtils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Created by IntelliJ IDEA.
 *
 * @author zq
 * @version 1.0
 * @create 2024-07-30 15:35
 * @since jdk1.8
 */
public class JDBCDemo04 {

    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            conn= JDBCUtils.getConnection();
            Statement statement = conn.createStatement();
            rs = statement.executeQuery("select * from userinfo");
            while (rs.next()){
                System.out.println(rs.getString("username"));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }finally {
            JDBCUtils.close(rs,ps,conn);
        }
    }
}
